﻿@page
@model AdminUI.Pages.Finance.CashApplyModel
@{
    var F = Html.F();
}
@section head {

    <style>
        .f-grid-row-summary .f-grid-cell-inner {
            font-weight: bold;
            color: red;
        }
    </style>

}
@section body {
    <f:Panel ID="Panel1" BodyPadding="5" ShowBorder="false" Layout="VBox" ShowHeader="false" IsViewPort="true">
        <Items>
            <f:Grid ID="Grid1" BoxFlex="1" ShowBorder="true" ShowHeader="false" EnableTextSelection="true" EnableColumnLines="true" EnableCheckBoxSelect="false" EnableMultiSelect="false" AllowSorting="true" AllowPaging="true" IsDatabasePaging="true"
                    DataIDField="ID" DataTextField="CashApplyName" PageSize="@ViewBag.PageSize" RecordCount="@ViewBag.Total" DataSource="@ViewBag.DataSource"
                    OnSort="@Url.Handler("Grid_DoAction")" OnSortFields="Panel1" SortingToolTip="true" SortingCancel="true" OnPageIndexChanged="@Url.Handler("Grid_DoAction")" OnPageIndexChangedFields="Panel1"
                    EnableSummary="true" SummaryPosition="Bottom" SummaryData="@ViewBag.Grid1SummaryData">
                <Toolbars>
                    <f:Toolbar ID="Toolbar1" ToolbarAlign="Right" ItemSpace="1">
                        <Items>
                            <f:Button ID="btnConfirm" IconAlign="Left" EnableDefaultState="false" IconFont="Money" Text="确认打款" OnClientClick="onConfirmClick();"></f:Button>
                            <f:ToolbarSeparator></f:ToolbarSeparator>
                            <f:Button ID="btnRefresh" IconAlign="Left" EnableDefaultState="false" IconFont="Refresh" Text="刷新" OnClientClick="onRefreshClick();"></f:Button>
                            <f:ToolbarFill ID="ToolbarFill1"></f:ToolbarFill>
                            <f:DatePicker ID="BeginDate" DateFormatString="yyyy-MM-dd" Label="开始日期" EmptyText="请选择开始日期" SelectedDate="DateTime.Now.AddYears(-1).Date" Width="220" LabelWidth="80">
                            </f:DatePicker>
                            <f:DatePicker ID="EndDate" Label=" 结束日期" CompareControl="BeginDate" DateFormatString="yyyy-MM-dd" SelectedDate="DateTime.Now.Date" CompareOperator="GreaterThanEqual" CompareMessage="结束日期应该大于开始日期" Width="220" LabelWidth="80">
                            </f:DatePicker>
                            <f:DropDownList ID="Condition" SelectedValue="" Width="150">
                                <f:ListItem Text="== 请选择条件 ==" Value="" />
                                <f:ListItem Text="会员ID" Value="UserID" />
                                <f:ListItem Text="会员姓名" Value="TrueName" />
                            </f:DropDownList>
                            <f:TriggerBox ID="Keyword" ShowLabel="false" EmptyText="请输入搜索关键字" TriggerIcon="Search" OnTriggerClick="@Url.Handler("Grid_DoAction")" OnTriggerClickFields="Panel1"></f:TriggerBox>
                        </Items>
                    </f:Toolbar>
                </Toolbars>
                <Columns>
                    <f:RowNumberField HeaderText="#" TextAlign="Center" />
                    <f:RenderField HeaderText="ID" DataField="ID" FieldType="Int" Hidden="true" Width="80" TextAlign="Center" />
                    @* <f:RenderField HeaderText="租户ID" DataField="TID" FieldType="Int" Width="80" TextAlign="Right" /> *@
                    <f:RenderField HeaderText="会员" DataField="UserID" FieldType="Int" Width="180" RendererFunction="renderMember" />
                    <f:RenderField HeaderText="会员姓名" DataField="TrueName" Width="100" Hidden="true" />
                    <f:RenderField HeaderText="提现金额" DataField="Amount" FieldType="Double" Width="100" TextAlign="Right" />
                    <f:RenderField HeaderText="转账目标" DataField="Target" FieldType="Int" Width="120" TextAlign="Center" RendererFunction="renderTarget" />
                    <f:RenderField HeaderText="交易流水号" DataField="TradeNo" Width="180" />
                    <f:RenderField HeaderText="操作员ID" DataField="OperatorID" FieldType="Int" Width="180" RendererFunction="renderOperator" />
                    <f:RenderField HeaderText="操作员姓名" DataField="OperatorName" Width="100" Hidden="true" />
                    <f:RenderField HeaderText="转账日期" DataField="PaymentTime" FieldType="Date" Renderer="Date" RendererArgument="yyyy-MM-dd" Width="120" TextAlign="Center" />
                    <f:RenderField HeaderText="申请时间" DataField="CreateTime" FieldType="Date" Renderer="Date" RendererArgument="yyyy-MM-dd HH:mm" Width="140" TextAlign="Center" />
                    <f:RenderField HeaderText="状态" DataField="Status" FieldType="Int" Width="80" TextAlign="Center" RendererFunction="renderStatus" />
                    <f:RenderField HeaderText="备注" DataField="Memo" MinWidth="100" ExpandUnusedSpace="true" />
                </Columns>
                <PageItems>
                    <f:ToolbarSeparator></f:ToolbarSeparator>
                    <f:ToolbarText Text="每页记录数："></f:ToolbarText>
                    <f:DropDownList ID="ddlGridPageSize" Width="60" DataSource="@new int[]{10,20,30,50,100,200}" SelectedValue="@ViewBag.PageSize"
                                    OnSelectedIndexChanged="@Url.Handler("Grid_DoAction")" OnSelectedIndexChangedFields="Panel1"></f:DropDownList>
                </PageItems>
            </f:Grid>
        </Items>
    </f:Panel>

    <f:Window ID="Window1" IsModal="true" Hidden="true" Target="Top" EnableResize="true" EnableMaximize="true" EnableIFrame="true" Width="750" Height="500">
        @*<Listeners>
    <f:Listener Event="close" Handler="onWindowClose('refresh');"></f:Listener>
    </Listeners>*@
    </f:Window>
}

@section script {
    <script src="~/res/js/grid.js"></script>
    <script>

        function onConfirmClick(event) {
            var grid1 = F.ui.Grid1;
            if (!grid1.hasSelection()) {
                showNotify('请选择要修改的记录！');
                return;
            }

            var selectedRow = grid1.getSelectedRow();
            var path = "/Finance/CashApplyConfirm?id=" + selectedRow;
            F.ui.Window1.show(path, '确认打款');
        }

        function onRefreshClick() {
            F.doPostBack('@Url.Handler("Grid_DoAction")', 'Panel1');
        }

        function renderMember(value, params) {
            return F.formatString('{0}-{1}', value, params.rowData.values.TrueName);
        }

        function renderOperator(value, params) {
            return F.formatString('{0}-{1}', value, params.rowData.values.OperatorName);
        }

        function renderTarget(value, params) {
            switch (value) { //转账目标：1-提现到银行卡，2-余额抵扣货款
                case 1:
                    return "<span class='tag-c1'>提现到银行卡</span>";
                case 2:
                    return "<span class='tag-c2'>余额抵扣货款</span>";
                default:
                    return "";
            }
        }

        function renderStatus(value, params) {
            switch (value) { //状态：0-申请中，1-已结算
                case 0:
                    return "<span class='tag-default'>申请中</span>";
                case 1:
                    return "<span class='tag-success'>已结算</span>";
                default:
                    return "";
            }
        }

    </script>
}